#ifndef _GLOBAL_TOOLS_H
#define  _GLOBAL_TOOLS_H
#include "stdafx.h"
#include <iostream>
#include "io.h"
#include "direct.h"

using namespace std;
class GTools
{
public:
	LPCSTR m_szPath;
	string m_subPath;
public:

	LPCSTR GetRootPathFileName( LPCTSTR filename)
	{
		static TCHAR path[MAX_PATH];// = {0} ;
		_tcscpy( path , m_szPath);
		_tcscat( path , filename);
		return path;
	}


 	LPCTSTR GetSubPathFileName()
	{
		static TCHAR path[MAX_PATH];// = {0} ;
		TCHAR buf[MAX_PATH]; 
		_tcscpy( buf ,  m_subPath.c_str());
		LPTSTR pch = (LPTSTR)_tcschr( buf , '.');
		pch[0] = '\0' ;
		_tcscpy( path , m_szPath);
		_tcscat( path ,  buf);
		if ( access( path , 0 ) == -1 )
		{
			mkdir( path )	;
		}
		_tcscat( path, _T("\\"));		
		return path;
	}

	LPCTSTR GetPathFileName( LPCTSTR filename)
	{
		static TCHAR path[MAX_PATH];// = {0} ;
		_tcscpy( path , GetSubPathFileName());
		_tcscat( path , filename);
		return path;
	}

	string replace_all(string str,const string   old_value,const string new_value)   
	{   
		while(true)   {   
			string::size_type   pos(0);   
			if(   (pos=str.find(old_value))!=string::npos   )   
				str.replace(pos,old_value.length(),new_value);   
			else   break;   
		}   
		return   str;   
	} 
};

#endif